@extends('admin.main')
@section('content')
    <div class="admin-biaogelist">

        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 栏目名称</ul>

            <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#"><a href="#">@if($data)编辑代金券@else添加代金券 @endif</a></dl>
        </div>

        <div class="fbneirong">
            <form class="am-form" action="{{urlAdmin('favorable','postAddFavorable')}}" method="post">
                {{--<div class="am-form-group am-cf">--}}
                    {{--<div class="zuo">可用项目：</div>--}}
                    {{--<div class="you">--}}
                        {{--<input type="text" class="am-input-sm" name="" id="doc-ipt-email-1" placeholder="请输入项目名称">--}}
                    {{--</div>--}}
                {{--</div>--}}
                <div class="am-form-group am-cf">
                    <div class="zuo">代金券名称：</div>
                    <div class="you">
                        <input type="text" class="am-input-sm" @if(isset($data))value="{{$data['data']['title']}}"@endif name="title" id="doc-ipt-pwd-1" placeholder="请输入折扣券名称">
                    </div>
                </div>
                <input type="hidden" value="{{$_GET['type']}}" name="type">
                <div class="am-form-group am-cf">
                    <div class="zuo">发放数量：</div>
                    <div class="you">
                        <input type="text" class="am-input-sm" @if(isset($data))value="{{$data['data']['num']}}"@endif name="num" id="doc-ipt-pwd-1" placeholder="请输入发放数量">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">券额：</div>
                    <div class="you">
                        <input type="text" @if(isset($data))value="{{$data['data']['cash']}}"@endif class="am-input-sm" name="cash" id="doc-ipt-pwd-1" placeholder="请输入券额">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">可使用用户类别：</div>
                    <div class="you" style="margin-top: 5px;">
                        <label class="am-checkbox-inline">
                            <input type="checkbox" name="user_type[]" checked value="1">
                            普通用户 </label>
                        <label class="am-checkbox-inline">
                            <input type="checkbox" name="user_type[]" value="2">
                            普通会员 </label>
                        <label class="am-checkbox-inline">
                            <input type="checkbox" name="user_type[]" value="3">
                            家庭会员 </label>
                    </div>
                </div>
                @if(isset($data))
                    <input type="hidden" name="id" @if(isset($data))value="{{$data['data']['id']}}"@endif>
                @endif

                <div class="am-form-group am-cf">
                    <div class="zuo">每人领取数量：</div>
                    <div class="you">
                        <input type="text" class="am-input-sm" @if(isset($data))value="{{$data['data']['recive_num']}}"@endif name="recive_num" id="doc-ipt-pwd-1" value="1" placeholder="请输入每人可领取数量">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">缩略图：</div>
                    <div class="you"><input type="file"  id="doc-ipt-file-1"><input type="hidden" name="pics" id="doc-ipt-file-2"> <img src="@if(isset($data))/{{$data['data']['imgs']}}@endif" id="prev_img" alt=""></div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">选择有效期：</div>
                    <div class="you"><input type="text" class="am-form-field am-input-sm am-input-zm am-icon-calendar" style="width: 100px; height: 30px;" placeholder="选择日期" data-am-datepicker="{theme: 'success',}"  @if(isset($data))value="{{$data['data']['end_time']}}"@endif name="end_time" readonly/>"></div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">内容：</div>
                    <div class="you">
                        <textarea class="" rows="2" name="desc" id="doc-ta-1"></textarea>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="you" style="margin-left: 11%;">
                        <button type="submit" class="am-btn am-btn-success am-radius">发布并关闭窗口</button>
                    </div>
                </div>
            </form>
        </div>
    @include('admin.footer')
@endsection
@section('script')
    <script>
        var message = "{{Session::get('message')}}";
        $(window).ready(function () {
            if (message) {
                layer.msg(message, {
                    time: 3000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        });
       var file = document.getElementById('doc-ipt-file-1');
       var img = document.getElementById('prev_img');
       file.onchange = function(){
           var oFReader = new FileReader();
           oFReader.readAsDataURL(this.files[0]);
           oFReader.onload = function (oFREvent) {
               document.getElementById('doc-ipt-file-2').value = oFREvent.target.result;
               img.src = oFREvent.target.result;
           };
       }
    </script>
@endsection
